<?php

/**
 * Формы гостевой книги
 */
class GuestbookForm extends Zend_Form {

    /**
     * Форма отзыва
     */
    public function edit($sid,$mid) {
        $this->setName('message');
        $t = Zend_Registry::get('Zend_Locale');
        $name = new Zend_Form_Element_Text('name');
        $name->setLabel('Name')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->setRequired();

        $text = new Zend_Form_Element_Textarea('text');
        $text->setLabel('Message')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->setRequired();

        $time = new Zend_Form_Element_Text('time');
        $time->setLabel('Time')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->setRequired();

        $active = new Zend_Form_Element_Checkbox('active');
        $active->setLabel('Active')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Save');
        $submit->setAttrib('id', 'submitbutton');

        $this->addElements(array($name,$time,$text,$active,$submit));

        $this->setAction(ADMIN_URL . '/pages/modify/id/' . $sid . '/a/edit/mid/' . $mid);
        $this->setDefaultTranslator($t);
        return $this;
    }

    /**
     * Форма добавления
     */
    public function add() {
        $this->setName('message');
        $t = Zend_Registry::get('Zend_Locale');
        $name = new Zend_Form_Element_Text('name');
        $name->setLabel('Name')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->setRequired();

        $text = new Zend_Form_Element_Textarea('text');
        $text->setLabel('Message')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->setRequired();

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Send');
        $submit->setAttrib('id', 'submitbutton');

        $this->addElements(array($name,$text,$submit));

        $this->setAction(SITE_URL . PAGE_URL);
        $this->setDefaultTranslator($t);
        return $this;
    }
}